import axios from '@/utils/request'



// 上传回答
export function uploadAnswer(content, userId, parentId) {
  return axios.post('/answers', {
    content,
    userId,
    parentId
  });
}

// 按时间升序获取问题的所有回答
export function getAllAnswersByQuestionIdASC(questionId, pageNum, pageSize) {
  return axios.get('/answers/asc', {
    params: {
      questionId,
      pageNum,
      pageSize
    }
  });
}

// 按时间降序获取问题的所有回答
export function getAllAnswersByQuestionIdDESC(questionId, pageNum, pageSize) {
  return axios.get('/answers/desc', {
    params: {
      questionId,
      pageNum,
      pageSize
    }
  });
}

// 根据id获取回答
export function getAnswerById(id) {
  return axios.get(`/answers/${id}`);
}

// 按时间降序获取用户的所有回答
export function getAnswersByUserIdDESC(userId, pageNum, pageSize) {
  return axios.get('/answers/user', {
    params: {
      userId,
      pageNum,
      pageSize
    }
  });
}
